<template>
        <div class="asideNav">
            <el-row v-for="(item, index) in navList" :key="index" type="flex" @mouseover.native="show(index)" @mouseleave.native="hide">
                <el-col :class="{'active': index === showIndex}">{{item.type}} <span>&gt;</span></el-col>
            </el-row>
            <div class="right" v-for="(item,index)  in navList" :key="item.id" >
                <ul v-show="index === showIndex" @mouseover="showDetail(index)" @mouseleave="hideDetail(index)">
                    <li v-for="(item1, index) in item.children" :key="index">
                        <span class="word">{{index+1}}</span><span class="city">{{item1.city}}</span> <span class="desc">{{item1.desc}}</span>
                    </li>
                </ul>
            </div>
        </div>
</template>

<script>
export default {
  name: '',
  data () {
    return {
      navList: [],
      navListChild: [],
      showIndex: 100,
      isShow: false
    }
  },
  methods: {
    show (index) {
      this.showIndex = index
    },
    hide () {
      this.showIndex = 100
    },
    isactive (index) {
      if (index === this.showIndex) {
        return true
      }
    },
    showDetail (index) {
      this.showIndex = index
    },
    hideDetail (index) {
      this.showIndex = 100
    }
  },
  mounted () {
    this.$http.get('/posts/cities').then(res => {
      res.data.data.forEach((item, index) => {
        const newData = { ...item, ...{ id: '0' + index } }
        this.navList.push(newData)
      })
    })
  }
}
</script>

<style lang="less" scoped>
.asideNav{
    position: relative;
    .el-row{
        width: 230px;
        height: 50px;
        font-size: 14px;
        line-height: 50px;
        border-radius: 2px;
        span{
            margin-left: 125px;
            font-size: 14px;
        }
        .el-col{
            border: solid 1px #eee;
            padding-left: 20px;
        }
        .active{
          border-right: 0px;
          color: orange;
        }
    }
    .right{
        width: 300px;
        position: absolute;
        left: 230px;
        top: 0;
        z-index: 5;
        ul{
            li{
                font-size: 14px;
                height: 50px;
                line-height: 50px;
                border: 1px solid #eee;
                border-left: 0;
                background-color: #fff;
                cursor: pointer;
                border-radius: 2px;
                .word{
                  color: orange;
                  font-size: 18px;
                  margin-left: 5px;
                }
                .city{
                  margin: 0 5px;
                  color: orange;
                }
                .desc{
                    color: rgb(185, 180, 180);
                }
            }
        }
    }
}
</style>
